//
//  LiXingMainTabbarVC.m
//  LiXingZuLin
//
//  Created by ypj on 2021/10/8.
//

#import "LiXingMainTabbarVC.h"
#import "KeHuViewController.h"
#import "CaoZuoViewController.h"
#import "CheLiangViewController.h"
#import "MessageViewController.h"
#import "LXHomeViewController.h"
#import "LXStatisticsViewController.h"

//#import "SiJiViewController.h"
@interface LiXingMainTabbarVC ()<UITabBarControllerDelegate>
@property (nonatomic, strong) NSString * orginSelected;

@end

@implementation LiXingMainTabbarVC

- (void)viewDidLoad {
    [super viewDidLoad];

    LXHomeViewController *firstVC = [[LXHomeViewController alloc] init];
    UINavigationController *firstNa = [self combinationViewController:firstVC  title:@"操作台" normalImg:@"home_unselectIcon" selectedImg:@"home_selectIcon"];
    
    MessageViewController  * messageVC = [[MessageViewController alloc] init];
    UINavigationController * messageVCNa = [self combinationViewController:messageVC  title:@"消息" normalImg:@"message_unselectIcon" selectedImg:@"message_selectIcon"];
    
    LXStatisticsViewController  *statistics = [[LXStatisticsViewController alloc] init];
    UINavigationController * statisticsVCNa = [self combinationViewController:statistics  title:@"统计" normalImg:@"tongji_unselectIcon" selectedImg:@"tongji_selectIcon"];
    
    
    CheLiangViewController *secondVC = [[CheLiangViewController alloc] init];
    UINavigationController *secondNa = [self combinationViewController:secondVC  title:@"车辆" normalImg:@"goods_unselectIcon" selectedImg:@"goods_selectIcon"];

    KeHuViewController *thiredVC = [[KeHuViewController alloc] init];
    UINavigationController *thriedNa = [self  combinationViewController:thiredVC  title:@"客户" normalImg:@"order_unselectIcon" selectedImg:@"order_selectIcon"];

    self.tabBar.tintColor = mainColor;
    self.tabBar.backgroundColor = White_Color;
//    self.viewControllers=@[firstNa,messageVCNa,siJiVCNa,secondNa,thriedNa];
    self.viewControllers = @[firstNa,messageVCNa,statisticsVCNa,secondNa,thriedNa];
    
    
}

- (UINavigationController *)combinationViewController:(UIViewController *)controller title:(NSString *)title normalImg:(NSString *)normalImg selectedImg:(NSString *)selectedImg{
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:controller];
    UITabBarItem *tabItem = [[UITabBarItem alloc]initWithTitle:title image:[UIImage imageNamed:normalImg] selectedImage:[[UIImage imageNamed:selectedImg] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    controller.tabBarItem = tabItem;
    return nav;
}

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
    self.orginSelected = item.title;
}

- (void)dealloc{
    self.viewControllers = nil;
}

@end
